<?php


require "./utility.php";
require "./types.php";

$conn = connect_mysql();

$query_str = "SELECT * FROM Book;";
$query = $conn->query($query_str);

$books = [];
while ($book_data = $query->fetch_row()) {
    $book = Book::fromArray($book_data);
    $books[] = $book;
}

$query->close();
$conn->close();

header("Content-Type: application/json");
echo json_encode($books, JSON_UNESCAPED_UNICODE);

